package panda.query.scan;

import java.util.Collection;

import panda.query.struct.Attribute;
import panda.query.struct.Constant;

/**
 * 
 * @author Tian Yuan
 */
public class ProjectScanner implements Scanner {
	
	private Scanner s;
	private Collection<Attribute> p;

	/**
	 * 
	 * @param s the scanner for the subtree of the projection node
	 * @param p the list of attribute names on which the node projects
	 */
	public ProjectScanner(Scanner s, Collection<Attribute> p) {
		this.s = s;
		this.p = p;
	}

	public void init() {
		s.init();
	}

	public boolean next() {
		return s.next();
	}

	public void close() {
		s.close();
	}

	public Constant getValue(Attribute attr) {
		return s.getValue(attr);
	}

	public boolean hasAttribute(Attribute name) {
		return p.contains(name);
	}
}
